[AS2] Use for variable as parameter and keep it different for each iteration
Posted
by Adam Kiss
on Stack Overflow
See other posts from Stack Overflow
or by Adam Kiss
Published on 2010-03-25T16:47:42Z
Indexed on
2010/04/29
16:27 UTC
Read the original article
Hit count: 370
Hello,
I have a basic for loop to loop through buttons and set some stuff and onPress handlers:
for (i=1;i<=20;i++){
//do some stuff
_root["button"+i].onPress = function(){ someMC.gotoAndStop(i+1); }
}
However, as I noticed, all buttonsthen link to one and same frame - all point to last i
+ 1 - Is there any possibility to call gotoAndStop
with "static" Number
, so in next iteration, it won't change?
Edit: Ex. for last statement:
Iteration 5 will call gAS /*gotoAndStop:]*/(6);
Iteration 6 -> gAS(7);
Iteration 7 -> gAS(8);
© Stack Overflow or respective owner